package com.test.design.pattern.iterator;

import java.util.List;

/**
 * @ClasName StudentIteratorImpl
 * @Descripution TODO
 * @Author USER
 * @Date 2022/2/25 9:01
 * @Version V1.0
 */
public class StudentIteratorImpl  implements  StudentIterator{


    private List<Student> list;
    private int position = 0;//用来记录遍历时的位置

    public StudentIteratorImpl(List<Student> list) {
        this.list = list;
    }

    public boolean hasNext() {
        return position < list.size();
    }

    public Student next() {
        Student currentStudent = list.get(position);
        position++;
        return currentStudent;
    }
}
